package com.leolian.spring02.activemq;

import javax.jms.JMSException;  
import javax.jms.Message;  
import javax.jms.MessageListener;  
import javax.jms.TextMessage;  

import org.springframework.stereotype.Component;
  
/** 
 * @description 通过监听的方式实现消费者 
 */
@Component
public class Lesson4Consumer implements MessageListener {  
  
    public void onMessage(Message message) {  
        TextMessage textMsg = (TextMessage) message;  
        try {  
            System.out.println("接收到了消息，消息内容是：" + textMsg.getText());  
        } catch (JMSException e) {  
            e.printStackTrace();  
        }  
    }  
  
}